// extends:关键字，继承
class Father {
    constructor(lastName) {
        this.lastName = lastName
    }
    say() {
        console.log(`My father’s last name is ${this.lastName}`);
    }
}

class Son extends Father {
    constructor(lastName, firstName, age) { //子类所有的属性传入
        super(lastName) //子类继承父类属性       Object.getPrototypeOf(Son).call(this.lastName)
        this.firstName = firstName //子类属性初始化
        this.age = age
    }
    sayAge() {
        super.say() //子类继承父类方法
        console.log(`My name is ${this.lastName}${this.firstName} ,${this.age}`);
    }
}

// let father = new Father('小罗布特')
// father.say()
let son = new Son('小罗布特', '唐尼', 20) //构造子类函数，传入需要的参数
son.sayAge() //调用子类的方法